package com.jayanslow.lighting.server.dmx;

public class DmxValue {
	public static int eight2sixteen(short s) throws OverflowException {
		if (s > 255 || s < 0) throw new OverflowException("8-bit DMX Value must be between 0x00 and 0xFF");
		return (s << 8);
	}
	public static short sixteen2eight(int i) throws OverflowException {
		if (i > 0xff00 || i < 0x0000) throw new OverflowException("16-bit DMX Value must be between 0x0000 and 0xFF00");
		short x = 0;
		if ((i & 0x00ff) > 0x7f) x += 1;
		return (short) ((i >> 8) + x);
	}
}
